/*
 * Interne Flags
 * USB und CAN wird nicht zugleich eingesetzt.
 */
typedef union _MYSTAT {
  unsigned char byte;
  struct {
	unsigned EMSRxFlag:1;		// data available at USART
	unsigned EMSTxFlag:1;		// data to sent with USART
	unsigned EMSTxReady:1;		// USART ready to send data
	unsigned EMSPoll:1;			// polled over EMS bus
    unsigned :4;
  } EMSbits;
  struct {
    unsigned :4;
	unsigned USBRxFlag:1;		// data available at USB
	unsigned USBTxFlag:1;		// data to sent with USB
	unsigned USBTxReady:1;		// CAN ready to send frames
	unsigned USBStopFlag:1;		// received break via USB
  } USBbits;
  struct {
    unsigned :4;
	unsigned CANRxFlag:1;		// data available at USB
	unsigned CANTxFlag:1;		// data to sent with USB
	unsigned CANTxReady:1;		// CAN ready to send frames
	unsigned CANStopFlag:1;		// received break via USB
  } CANbits;
} MYSTAT;

extern MYSTAT mystat;

typedef struct {
	  unsigned CAN:1;	// 1=CAN-mode	0=PC-mode (RC4)
	  unsigned RAW:1;	// 1=RAW	  	0=HEX	  (RC3)
	  unsigned POLL:1;	// 1=Yes		0=No polling	(RC2)
	  unsigned :5;
} CONTROLERCONF;

extern CONTROLERCONF controlerconf;


// Funktionen aus lcd.c
void writeLCDData(unsigned char zeichen);
void writeLCDCmd(unsigned char zeichen);

// Funktionen aus usb.c
void sendEmsUSBRaw(void);
void sendEmsUSBHex(void);

// Funktionen in ems.c
void sendEMStel(void);
void waitTxEMS(void);
void transmitEMS(unsigned char byte);
void waitRxEMS(void);
